#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 5e5+10;

int sum[N<<5],ls[N<<5],rs[N<<5],s[N],fl[N],fr[N],n,k,L,R,a[N],mx,tot,tain[N],rt[N],now[N],mn;
ll ans;

void insert(int &y,int x,int pos,int l = mn,int r = mx){
	y = ++tot; ls[y] = ls[x]; rs[y] = rs[x]; sum[y] = sum[x] + 1;
	if(l == r) return; int mid = l + r >> 1;
	if(pos <= mid) insert(ls[y],ls[x],pos,l,mid);else insert(rs[y],rs[x],pos,mid+1,r);
}

int query(int y,int x,int k,int l = mn,int r = mx){
	if(l == r) return l;
	int mid = l + r >> 1,sz = sum[ls[y]] - sum[ls[x]];
//	cerr<<"K"<<k<<"..."<<sz<<":"<<l<<"..."<<r<<endl;
	if(k > sz) return query(rs[y],rs[x],k - sz,mid+1,r);
	else return query(ls[y],ls[x],k,l,mid);
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,k = in,L = in,R = in;
	for(int i = 1;i <= n;i++) a[i] = in,s[i] = s[i-1] + a[i],mx = max(mx,s[i]),mn = min(mn,s[i]);
	for(int i = 0;i <= n;i++) insert(rt[i+1],rt[i],s[i]);
	priority_queue<pii > q;
	for(int i = 1;i <= n;i++) fl[i] = max(i - R + 1,1),fr[i] = i - L + 1,tain[i] = fr[i] - fl[i] + 1;
	for(int i = 1;i <= n;i++) if(tain[i] > 0) now[i] = 1,q.push(pii(s[i] - query(rt[fr[i]],rt[fl[i]-1],now[i]),i));
	while(k--){
		ans += q.top().fi; int x = q.top().se; q.pop();
		if(now[x] < tain[x]) q.push(pii(s[x] - query(rt[fr[x]],rt[fl[x]-1],++now[x]),x));
	}
	printf("%lld\n",ans);
	return 0;
}

